﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Services;
using Common;
using EntityModel;
using System.Data.Entity;
using MvcPaging;
namespace Heart.Controllers
{
    public class ArticleTypeController : Controller
    {
        #region 公用属性
        private ArticleTypeService articleTypeService = new ArticleTypeService();
        private int pageSize = ConfigHelper.PageSize();
        #endregion
       

        public ActionResult Index(int? page)
        {
            int PageIndex = page.HasValue ? (page.Value == 0 ? 0 : (page.Value - 1)) : 0;
            var list = articleTypeService.GetAllList().ToPagedList(PageIndex, pageSize);
            return View(list);
        }

        public ActionResult Create()
        {
            IEnumerable<ArticleType> list = articleTypeService.GetList();
            ViewData["list"] = new SelectList(list, "Id", "Name");
            return View();
        }
        [HttpPost]
        public ActionResult Create(FormCollection model)
        {
            ArticleType c = new ArticleType();
            c.Name = WebBase.GetForm("Name");
            c.Status = (int)EnumModel.Status.Show;
            c.DisplayOrder = WebBase.GetFormInt("DisplayOrder");
            articleTypeService.Create(c);
            return RedirectToAction("Index");
        }




    }
}
